<script setup>
import { ref, onMounted } from 'vue'
// 引入 echarts 核心模块，核心模块提供了 echarts 使用必须要的接口。
import * as echarts from 'echarts/core'
// 引入柱状图图表，图表后缀都为 Chart
import { LineChart } from 'echarts/charts'
// 引入提示框，标题，直角坐标系，数据集，内置数据转换器组件，组件后缀都为 Component
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent
} from 'echarts/components'
// 标签自动布局、全局过渡动画等特性
import { LabelLayout, UniversalTransition } from 'echarts/features'
// 引入 Canvas 渲染器，注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import { CanvasRenderer } from 'echarts/renderers'

// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  LineChart,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer
])
const sellLine = ref('')
const chartInstance = ref(null)
const option = ref({
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line'
    }
  ]
})
//挂载调用
onMounted(() => {
  chartInstance.value = echarts.init(sellLine.value)
  chartInstance.value.setOption(option.value)
})

const dateValue = ref(null)
console.log(dateValue.value)
// 分页
const form = ref({
  pageNum: 1,
  pageSize: 10
})
const pageChange = (newPage) => {
  form.value.pageNum = newPage
}
const total = ref(200)
</script>
<template>
  <div class="container">
    <div class="header">
      <div class="firstbox tabBox">
        <div>
          <el-date-picker
            v-model="dateValue"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            size="large"
            :default-value="[new Date(2023, 3, 1), new Date(2023, 6, 19)]"
          />
        </div>
      </div>
      <div class="echartBox">
        <div ref="sellLine" style="width:1200px;height: 500px;"></div>
      </div>
      <!-- // -->
      <div class="titleBox">
        <h3>客户统计报表</h3>
      </div>
      <!-- /// -->
      <div class="searchBox">
        <el-form :inline="true" label-position="top">
          <el-form-item label="归属部门">
            <el-select placeholder="请选择" size="large" style="width: 280px"></el-select>
          </el-form-item>
        </el-form>
        <div style="margin-top: 30px">
          <el-button type="success" round size="large" style="width: 94px">搜索</el-button>
          <el-button type="info" round size="large" style="width: 94px">重置</el-button>
        </div>
      </div>
      <!-- //// -->
      <div class="tableBox">
        <el-table :data="tableData" style="width: 100%" stripe>
          <el-table-column label="排行" />
          <el-table-column label="归属人" />
          <el-table-column label="合同数量" />
          <el-table-column label="成交金额" />
        </el-table>
        <el-row type="flex" justify="center">
          <el-pagination
            v-model:current-page="form.pageNum"
            v-model:page-size="form.pageSize"
            :page-sizes="[10, 20, 30, 50]"
            :small="small"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @current-change="pageChange"
            @size-change="pageSizeChange"
          />
        </el-row>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.container {
  background-color: #fff;
  .tabBox {
    display: flex;
    justify-content: space-between;
    padding: 14px 20px;
  }
  .titleBox {
    height: 83px;
    line-height: 83px;
    padding-left: 21px;
    background-color: #f9f9f9;
  }
  .searchBox {
    display: flex;
    justify-content: space-between;
    padding: 10px 56px 40px 45px;
  }
  :deep(.el-input__wrapper) {
    border-radius: 10px;
    background-color: #f9f9f9;
  }
}
</style>
